package me.zhengjie.modules.personPayoutQuery.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.basic.mapper.BasicAb01Mapper;
import me.zhengjie.modules.personPayoutQuery.domain.dto.PersonPayoutQueryCriteria;
import me.zhengjie.modules.personPayoutQuery.mapper.PersonPayoutQueryMapper;
import me.zhengjie.modules.personPayoutQuery.service.PersonPayoutQueryService;
import me.zhengjie.util.ValidateUtil;
import me.zhengjie.utils.PageResult;
import me.zhengjie.utils.PageUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
@Transactional
public class PersonPayoutQueryServiceImpl implements PersonPayoutQueryService {

    @Resource
    private PersonPayoutQueryMapper personPayoutQueryMapper;
    @Resource
    private BasicAb01Mapper basicAb01Mapper;

    @Override
    public PageResult<PersonPayoutQueryCriteria> queryList(Map param, Page<Object> page) {
        List<PersonPayoutQueryCriteria> dataList = personPayoutQueryMapper.getList(param, page);
        // 数据处理
        if (!ValidateUtil.isEmpty(dataList)) {
            dataList.forEach(item ->{
                BigDecimal je1_tf = new BigDecimal(item.getJe1_tf());
                BigDecimal je2_tf = new BigDecimal(item.getJe2_tf());
                BigDecimal je1_zy = new BigDecimal(item.getJe1_zy());
                BigDecimal je2_zy = new BigDecimal(item.getJe2_zy());
                item.setJe1_tf(je1_tf.negate().toString());
                item.setJe2_tf(je2_tf.negate().toString());
                item.setJe1_zy(je1_zy.negate().toString());
                item.setJe2_zy(je2_zy.negate().toString());
            });
        }

            return PageUtil.toPage(dataList);
    }

}
